package app.itgungnir.compose.wan.business.coin_manifest

import android.content.res.Configuration
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.width
import androidx.compose.material.MaterialTheme
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import app.itgungnir.compose.wan.theme.WanComposePreviewTheme
import app.itgungnir.compose.wan.widgets.WanCardRow
import app.itgungnir.compose.wan.widgets.WanDescription
import app.itgungnir.compose.wan.widgets.WanHeader

@Composable
fun CoinManifestItem(item: CoinManifest?) {
    item ?: return
    WanCardRow(verticalAlignment = Alignment.CenterVertically) {
        WanHeader(content = "+${item.coinCount}", color = MaterialTheme.colors.primary)
        Spacer(modifier = Modifier.width(15.dp))
        WanDescription(content = item.desc)
    }
}

@Preview(name = "CoinManifestItem light mode", showBackground = false)
@Preview(name = "CoinManifestItem dark mode", uiMode = Configuration.UI_MODE_NIGHT_YES, showBackground = false)
@Composable
private fun CoinManifestItemPreview() {
    WanComposePreviewTheme {
        CoinManifestItem(
            CoinManifest(
                coinCount = 28,
                desc = "2021-10-25 17:21:27 签到 , 积分：12 + 3"
            )
        )
    }
}
